<template>
  <el-dropdown trigger="click" @command="handleSetLanguage">
    <div>
      <svg-icon class-name="size-icon" icon-class="language" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item v-for="item of langOptions" :key="item.value" :command="item.value">
        {{
          item.label }}
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import { setup } from '@/language';
export default {
  data() {
    return {
      langOptions: [
        { label: this.$t('chinese'), value: 'zh' },
        { label: this.$t('english'), value: 'en' }
      ]
    }
  },
  methods: {
    async handleSetLanguage(lang) {
      setup(lang);
    }
  }

}
</script>
